package cn.gok.day6.controller;

import cn.gok.day6.entity.Clazz;
import cn.gok.day6.service.ClazzService;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/clazz")
public class ClazzController {
    @Resource
    @Autowired
    private ClazzService clazzService;

    @RequestMapping("/findAll")
    public List<Clazz> findAllClazz(){
        return clazzService.list(null);
    }
    @RequestMapping("/findById")
    public Clazz findClazzById(@RequestParam Long id){
        return clazzService.getById(id);
    }
    @RequestMapping("/save")
    public  boolean saveClazz(@RequestBody Clazz clazz){
        return clazzService.save(clazz);
    }
    @RequestMapping("/update")
    public boolean updateClazzById(@RequestBody Clazz clazz){
        return clazzService.updateById(clazz);
    }
    @RequestMapping("/removById")
    public boolean removeClazz(@RequestParam Long id){
        return clazzService.removeById(id);
    }
    @RequestMapping("/removeByIds")
    public boolean removeClazzByIds(@RequestBody List<Integer> ids){
        return clazzService.removeByIds(ids);
    }
}
